package com.common.help;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class SyncTest {

	public void test(int j){
		synchronized (SyncTest.class) {
			for(int i=0;i<10;i++){
				System.out.println("test--"+j+"--"+i);
			}
		}
	}
	public synchronized void test1(int j){
		for(int i=0;i<10;i++){
			System.out.println("test1--"+j+"--"+i);
		}
	}
	
	public static void main(String[] args) {
		final SyncTest  sync = new SyncTest();
		final SyncTest  sync1 = new SyncTest();
		System.out.println(sync.equals(sync1));
		ExecutorService pool = Executors.newCachedThreadPool();
		pool.execute(new Runnable() {
			@Override
			public void run() {
				sync.test(1);
			}
		});
		
		pool.execute(new Runnable() {
			@Override
			public void run() {
				sync1.test(2);
			}
		});
	}
}
